
function EventEmitter() {
  this.subs = {}
}


// 注册事件
EventEmitter.prototype.$on = function(EventType, handler) {
  this.subs[EventType] = this.subs[EventType] || []
  this.subs[EventType].push(handler)
}



// 触发事件
EventEmitter.prototype.$emit = function(EventType,...rest) {
  if(this.subs[EventType]) {
    this.subs[EventType].forEach(handler => {
      handler.call(this,...rest)
    });
  }
}

const bus = new EventEmitter()